clc;
clear;
A=[5,7,6,5;
    7,10,8,7;
    6,8,10,9;
    5,7,9,10];

while(1),
    x=randi([0,1],[4,1]);
    T=sym([x A*x A^2*x A^3*x]);
    if rank(T)==4,
        break;
    end,
end,
T,
A1=inv(T)*A*T

T1=inv(T*fliplr(eye(4)))',
A2=inv(T1)*A*T1